/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



package Presentacion;

/**
 *
 * @author Analia
 */
public class FrameConfiguracion extends javax.swing.JFrame
{

       private FramePrincipal frmPrincipalAux;


    /** Creates new form FrameConfiguracion */
    public FrameConfiguracion(FramePrincipal frmPrincipal)
    {

        this.frmPrincipalAux = frmPrincipal;

        initComponents();
    }


    public FramePrincipal getFrmPrincipalAux()
    {
        return this.frmPrincipalAux;
    }

    public void setFrmPrincipalAux(FramePrincipal frmPrincipalAux)
    {
        this.frmPrincipalAux = frmPrincipalAux;
    }



    public void cargarCampos()
    {
   
        this.frmPrincipalAux.getConfiguracion().setDominio(EditDominio.getText());
        this.frmPrincipalAux.getConfiguracion().setPuertoSMTP(Integer.parseInt(EditSMTP.getText()));
        this.frmPrincipalAux.getConfiguracion().setPuertoPOP(Integer.parseInt(EditPOP3.getText()));
        this.frmPrincipalAux.getConfiguracion().setCorreo(EditUsuario.getText());
        this.frmPrincipalAux.getConfiguracion().setContrasena(new String(EditContrasena.getPassword()));

    }

     private void mostrarPrincipal()
     {
        frmPrincipalAux.setVisible(true);
        this.setVisible(false);
    }

    private void configuracionOriginal()
    {
        EditDominio.setText("virtual.fcet.uagrm.edu.bo");
        EditSMTP.setText("25");
        EditPOP3.setText("110");
        EditUsuario.setText("grupo7sa");
        EditContrasena.setText("grupo7grupo7");
        cargarCampos();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        LabelTitulo = new javax.swing.JLabel();
        LabelDominio = new javax.swing.JLabel();
        LabelSMTP = new javax.swing.JLabel();
        LabelPOP3 = new javax.swing.JLabel();
        LabelUsuario = new javax.swing.JLabel();
        LabelContrasena = new javax.swing.JLabel();
        EditDominio = new javax.swing.JTextField();
        EditSMTP = new javax.swing.JTextField();
        EditPOP3 = new javax.swing.JTextField();
        EditUsuario = new javax.swing.JTextField();
        EditContrasena = new javax.swing.JPasswordField();
        BotonOK = new javax.swing.JButton();
        BotonCancelar = new javax.swing.JButton();
        BotonReset = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        LabelTitulo.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        LabelTitulo.setText("CONFIGURACION DE LA CONEXION");

        LabelDominio.setText("Dominio");

        LabelSMTP.setText("Puerto SMTP");

        LabelPOP3.setText("Puerto POP3");

        LabelUsuario.setText("Usuario");

        LabelContrasena.setText("Contraseña");

        EditDominio.setText("virtual.fcet.uagrm.edu.bo");

        EditSMTP.setText("25");

        EditPOP3.setText("110");

        EditUsuario.setText("grupo14sa");

        EditContrasena.setText("grupo7grupo7");

        BotonOK.setText("OK");
        BotonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonOKActionPerformed(evt);
            }
        });

        BotonCancelar.setText("Cancelar");
        BotonCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonCancelarActionPerformed(evt);
            }
        });

        BotonReset.setText("Reset");
        BotonReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonResetActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(58, 58, 58)
                .addComponent(LabelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(60, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(LabelContrasena)
                        .addGap(18, 18, 18)
                        .addComponent(EditContrasena, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(LabelDominio)
                                .addComponent(LabelUsuario)
                                .addComponent(LabelSMTP))
                            .addComponent(LabelPOP3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(EditPOP3, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(EditUsuario, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE)
                                .addComponent(EditDominio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(EditSMTP, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)
                                    .addGap(148, 148, 148))))))
                .addGap(52, 52, 52))
            .addGroup(layout.createSequentialGroup()
                .addGap(85, 85, 85)
                .addComponent(BotonOK)
                .addGap(39, 39, 39)
                .addComponent(BotonCancelar)
                .addGap(38, 38, 38)
                .addComponent(BotonReset)
                .addContainerGap(104, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(LabelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelDominio, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EditDominio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EditSMTP, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelSMTP))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(LabelPOP3)
                    .addComponent(EditPOP3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(LabelUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EditUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(EditContrasena, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LabelContrasena))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BotonOK)
                    .addComponent(BotonCancelar)
                    .addComponent(BotonReset))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BotonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonOKActionPerformed

        cargarCampos();
        mostrarPrincipal();
    }//GEN-LAST:event_BotonOKActionPerformed

    private void BotonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonCancelarActionPerformed

        configuracionOriginal();
        mostrarPrincipal();
    }//GEN-LAST:event_BotonCancelarActionPerformed

    private void BotonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonResetActionPerformed

        configuracionOriginal();
    }//GEN-LAST:event_BotonResetActionPerformed

    /**
    * @param args the command line arguments
    */
 /*   public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameConfiguracion().setVisible(true);
            }
        });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonCancelar;
    private javax.swing.JButton BotonOK;
    private javax.swing.JButton BotonReset;
    private javax.swing.JPasswordField EditContrasena;
    private javax.swing.JTextField EditDominio;
    private javax.swing.JTextField EditPOP3;
    private javax.swing.JTextField EditSMTP;
    private javax.swing.JTextField EditUsuario;
    private javax.swing.JLabel LabelContrasena;
    private javax.swing.JLabel LabelDominio;
    private javax.swing.JLabel LabelPOP3;
    private javax.swing.JLabel LabelSMTP;
    private javax.swing.JLabel LabelTitulo;
    private javax.swing.JLabel LabelUsuario;
    // End of variables declaration//GEN-END:variables

}
